package org.iteam.bank.signed.service;

import java.util.List;

import org.iteam.bank.core.Constant;
import org.iteam.bank.signed.model.BankRegion;
import org.iteam.db.SimpleDbRunner;
import org.iteam.db.exception.DbException;

/**
 * 银行 地区
 * 
 * @author wenke
 *
 */
public class BankRegionService {

	public static BankRegionService getInstance() {
		return Subclass.service;
	}

	private static final class Subclass {
		public static final BankRegionService service = new BankRegionService();
	}

	private BankRegionService() {
		super();
	}

	public List<BankRegion> queryAll() throws DbException {
		String sql = "select * from bank_region order by id ";
		return new SimpleDbRunner(Constant.MYSQL_PAY).findBeanList(BankRegion.class, sql);
	}

	public List<BankRegion> queryAll(String parent_id) throws DbException {
		String sql = "select * from bank_region where parent_id = ?  order by id  ";
		return new SimpleDbRunner(Constant.MYSQL_PAY).findBeanList(BankRegion.class, sql, parent_id);
	}

	public List<BankRegion> queryRoot() throws DbException {
		String sql = "select * from bank_region where parent_id = 0  order by id  ";
		return new SimpleDbRunner(Constant.MYSQL_PAY).findBeanList(BankRegion.class, sql);
	}
}
